package com.xayoudao.uneng.domain;

import java.util.ArrayList;
import java.util.Date;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class Subarea {
	int id;
	double lat;
	double lng;
	String description;
	String title;
	String adds;
	String hotline;
	int evaluation;
	int percost;
	Date createtime;

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public double getLat() {
		return lat;
	}

	public void setLat(double lat) {
		this.lat = lat;
	}

	public double getLng() {
		return lng;
	}

	public void setLng(double lng) {
		this.lng = lng;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getAdds() {
		return adds;
	}

	public void setAdds(String adds) {
		this.adds = adds;
	}

	public String getHotline() {
		return hotline;
	}

	public void setHotline(String hotline) {
		this.hotline = hotline;
	}

	public int getEvaluation() {
		return evaluation;
	}

	public void setEvaluation(int evaluation) {
		this.evaluation = evaluation;
	}

	public int getPercost() {
		return percost;
	}

	public void setPercost(int percost) {
		this.percost = percost;
	}

	public Date getCreatetime() {
		return createtime;
	}

	public void setCreatetime(Date createtime) {
		this.createtime = createtime;
	}

	// 解板服务器返回的用户的json信息到User对象
	public static ArrayList<Subarea> parser(JSONArray array) {

		Subarea object = null;
		ArrayList<Subarea> list = new ArrayList<Subarea>();
		int length = array.length();

		for (int i = 0; i < length; i++) {// 遍历JSONArray
			try {
				JSONObject obj = array.getJSONObject(i);

				object = new Subarea();
				object.setId(obj.optInt("id"));
				object.setLat(obj.optDouble("lat"));
				object.setLng(obj.optDouble("lng"));
				obj.getString("hotline");
				list.add(object);
			} catch (JSONException e) {
				e.printStackTrace();
			}
		}

		return list;
	}

	@Override
	public String toString() {
		return "Subarea [id=" + id + ", lat=" + lat + ", lng=" + lng
				+ ", description=" + description + ", title=" + title
				+ ", adds=" + adds + ", hotline=" + hotline + ", evaluation="
				+ evaluation + ", percost=" + percost + ", createtime="
				+ createtime + "]";
	}

}
